<template>
  <div>
    <div class="table-page-search-wrapper">
      <a-form-model
        layout="inline"
        :model="queryParam"
      >
        <a-row :gutter="15">
          <a-col :md="6" :sm="24">
            <a-form-model-item label="被叫">
              <a-input v-model="queryParam['filter[dst]']"/>
            </a-form-model-item>
          </a-col>
          <a-button type="primary" @click="$refs.table.refresh(true)">搜索</a-button>
          <a-button style="margin-left: 8px" @click="resetForm">重置</a-button>
        </a-row>
      </a-form-model>
    </div>
    <s-table
      bordered
      ref="table"
      :row-key="(record) => record.id"
      :columns="kaolaColumns"
      :data="kaolaData"
    >
      <template slot="url" slot-scope="text">
        <audio :src="text" controls :style="{ height: '20px', lineHeight: '20px' }">
          您的浏览器不支持 audio 标签
        </audio>
      </template>
    </s-table>
  </div>
</template>

<script>
import { STable } from '@/components'
import col from '@/columns/calls'
import { getCallList } from '@/api/calls'
const kaolaColumns = col.kaola

export default {
  components: {
    STable
  },
  name: 'KaoLa',
  data () {
    return {
      kaolaColumns,
      kaolaData: parameters => {
        return getCallList(Object.assign(parameters, this.queryParam)).then(res => {
          return res.result
        })
      },
      advanced: true,
      queryParam: {}
    }
  },
  created () {
    this.queryParam['filter[type]'] = '1'
  },
  methods: {
    resetForm () {
      const app = this
      app.queryParam = {}
      app.queryParam['filter[type]'] = '1'
      app.$refs.table.refresh(true)
    }
  }
}
</script>

<style scoped>

</style>
